// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    taskActive: 0,
    taskActiveX: 0,
    tabList: [
      '每日任务',
      '每周任务',
      '每年任务'
    ]
  },
  onLoad() {
  },
  onReady: function () {
    // 初始化
    this.currentTab()
  },
  currentTab(e) {
    const query = wx.createSelectorQuery()
    var _this = this
    var idx = e == undefined ? 0 : e.currentTarget.dataset.idx
    var className = '.task-tab' + idx
    setTimeout(() => {
      query.select(className).boundingClientRect()
      query.exec(function (res) {
        _this.setData({
          taskActive: idx,
          taskActiveX: res[0].left
        })
      })
    }, 0);
  }
})
